#ifndef _KEYCAPTURE_H
#define	_KEYCAPTURE_H

#include <Carbon/Carbon.h>

class KeyCapture
{
private:
    ProcessSerialNumber m_focusedAppPSN;
    pid_t m_focusedAppPID;
    AXUIElementRef m_focusedApp;
    AXUIElementRef m_focusedAppElement;
    AXObserverRef m_focusedAppObserver;

    static OSStatus AppFrontSwitchedHandler(EventHandlerCallRef inHandlerCallRef,
        EventRef inEvent, void *inUserData);
    bool InstallAXUIEventMonitor(pid_t pid);
    static void FocusedWindowChangedHandler(AXObserverRef observer, AXUIElementRef element,
        CFStringRef notification, void *refcon);
    void UninstallAXUIEventMonitor();
    void ObserveKeyDown(AXUIElementRef element);

public:
    KeyCapture();
    ~KeyCapture();
    CFRunLoopRef m_runLoop;

};

#endif	/* _KEYCAPTURE_H */

